<div id="content">
             <div class="filter_bar"><div class="fb_title">Bài mới</div></div>
      <div id="content_inner">
				<!--Wigitized 'Alert' for the home page -->
	
	 <div id="blog_wrapper">
	 <?php if(!empty($data)): ?>
        <?php $cate = $this->config->item('categories'); ?>
        <?php $permalink = '';$arrUri = array();$i = 1; ?>
	 	<?php foreach($data as $post): ?>
        <?php $post->post_title = strip_tags($post->post_title); $permalink = permalink(array('text' => $post->post_title, 'id' => $post->id)); ?>
        <?php
        $arrUri[] = $permalink;
        ?>
        <ul class="lp_lists" id="list_items-<?php echo $i; ?>">
        <li class="lp_container">
            <div class="lp_left">
                <div class="lp_desc">
                 <a href="<?php echo $permalink; ?>">
                    <img src="<?php echo FARM_URL.'460x460/'.$post->post_image ?>" width="460" />
                    <?php if($post->item_type == 'video'): ?>
                    <div class="video-indicator"></div>
                    <?php endif; ?>
                    <?php if($post->item_type == 'gif'): ?>
                    <div class="gif-indicator"></div>
                    <?php endif; ?>
                 </a>
                </div>
            </div><!--lp left ends-->
            <div class="lp_right" id="title-fixed-<?php echo $i; ?>">
                <div class="lp_title">
                   <a href="<?php echo $permalink; ?>"><?php echo $post->post_title ?></a>
                </div>
                <div class="lp_category">
                    <a href="<?php echo BASE_URL.'/'.$cate[$post->category_id][0]; ?>" title="<?php echo $cate[$post->category_id][1]; ?>" rel="category tag" class="cate_tag"><?php echo $cate[$post->category_id][1]; ?></a>                    </div>
                <div class="lp_dates">Gửi <?php echo facebookTime($post->crawl_date) ?></div>
                <div class="lp_comments">
                    <div class="lpc_butt">
                        <div class="view_icon"><?php echo number_format($post->view) ?></div>
                    </div>
                    <div class="lpc_butt" style="border:none !important;">
                       <div class="comment_icon" id="cmt-<?php echo $post->id ?>">
                        <?php
                        //$fb = getFacebookCount($permalink);
                        //echo number_format((int)$fb->comment_count);
                       ?></div>
                    </div>
                </div>
                <div class="lpc_sharing">
                    <div class="lpcs_top">
                    </div>
                    <div class="lpcs_bottom">

                            <div class="lpcs_sbutt">
                                <a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo $permalink ?>" data-text="<?php echo $post->post_title ?>" data-count="horizontal"></a>
                            </div>
                            <div class="lpcs_sbutt" id="lpcs_fbutt" >
                                <div class="fb-like" data-href="<?php echo $permalink ?>" data-send="false" data-layout="button_count" data-width="200" data-show-faces="true"></div>
                            </div>

                    </div>
                </div>
            </div><!--lp right ends-->
            <div style="clear: both;"></div>
        </li><!--lp container ends-->
        </ul>
        <div style="clear: both;"></div>
    	<?php $i++;endforeach; ?>
        <?php
        $strUri = base64_encode(implode(',', $arrUri));
        ?>
    <?php endif; ?>
    </div>
    <div class="btn-view-more" id="more-btn"><a href="#" id="more-link">Xem thêm • • •</a></div>
	<!--<div class="page-link">
	<?php #echo $paging; ?>
    </div>-->
         </div><!--content_inner ends-->
</div><!--#content-->
<script type="text/javascript">
var page = <?php echo (int)$page; ?>;

$(document).ready(function(){
    var uris = '<?php echo $strUri; ?>';
    /*var uris = 'aHR0cDovL3d3dy5oYWl2bC5jb20vcGhvdG8vNTk3ODI1LGh0dHA6Ly93d3cuaGFpdmwuY29tL3Bob3RvLzU5MjEwOSxodHRwOi8vd3d3LmhhaXZsLmNvbS9waG90by81OTY5MzMsaHR0cDovL3d3dy5oYWl2bC5jb20vcGhvdG8vNTk1MzA1LGh0dHA6Ly93d3cuaGFpdmwuY29tL3Bob3RvLzU5MzUyNixodHRwOi8vd3d3LmhhaXZsLmNvbS9waG90by81OTc4NjIsaHR0cDovL3d3dy5oYWl2bC5jb20vcGhvdG8vNTk1NTc2LGh0dHA6Ly93d3cuaGFpdmwuY29tL3Bob3RvLzU5NjI5MixodHRwOi8vd3d3LmhhaXZsLmNvbS9waG90by81ODc5OTgsaHR0cDovL3d3dy5oYWl2bC5jb20vcGhvdG8vNjAwMTgw';*/
    $.ajax({
        url: "<?php echo BASE_URL.'/ajax/fb' ?>",
        type: 'POST',
        dataType: 'json',
        data: {'url':uris},
        }).done(function(data){
            if(data.length > 0){
                i = 0;
                $('.comment_icon').each(function(i, obj) {
                    $(obj).html(data[i].like_count);
                    i++;
                });
            }
        });
    //
    hasReach = false;
    $(window).scroll(function() {
       if($(window).scrollTop() + $(window).height() > $(document).height() - 300) {
           //$(window).unbind('scroll');
           if(hasReach) return;
           hasReach = true;
           totalItem = $('#blog_wrapper > ul').size();
           offset = totalItem+page;
           if(totalItem >= <?php echo HOME_LIMIT*LIMIT_LOAD_MORE_PAGE ?>){
            $('#more-btn').show();
            $('#more-link').attr('href', BASE_URL+'/page/'+offset);
           }
           else{
               $.ajax({
                url: "<?php echo BASE_URL.'/ajax/loadmore' ?>",
                type: 'POST',
                data: {'offset':offset},
                }).done(function(data){
                    $('#blog_wrapper').append(data);
                    hasReach = false;
                });
            }
       }
    });
});
</script>